// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#include "error_bluetooth.hpp"
#include <module-bluetooth/lib/btstack/src/bluetooth.h>

namespace bluetooth
{
    const char *error_cstr(int err)
    {
        switch (err) {
        case ERROR_CODE_SUCCESS:
            return "ERROR_CODE_SUCCESS";
        case ERROR_CODE_UNKNOWN_HCI_COMMAND:
            return "ERROR_CODE_UNKNOWN_HCI_COMMAND";
        case ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER:
            return "ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER";
        case ERROR_CODE_HARDWARE_FAILURE:
            return "ERROR_CODE_HARDWARE_FAILURE";
        case ERROR_CODE_PAGE_TIMEOUT:
            return "ERROR_CODE_PAGE_TIMEOUT";
        case ERROR_CODE_AUTHENTICATION_FAILURE:
            return "ERROR_CODE_AUTHENTICATION_FAILURE";
        case ERROR_CODE_PIN_OR_KEY_MISSING:
            return "ERROR_CODE_PIN_OR_KEY_MISSING";
        case ERROR_CODE_MEMORY_CAPACITY_EXCEEDED:
            return "ERROR_CODE_MEMORY_CAPACITY_EXCEEDED";
        case ERROR_CODE_CONNECTION_TIMEOUT:
            return "ERROR_CODE_CONNECTION_TIMEOUT";
        case ERROR_CODE_CONNECTION_LIMIT_EXCEEDED:
            return "ERROR_CODE_CONNECTION_LIMIT_EXCEEDED";
        case ERROR_CODE_SYNCHRONOUS_CONNECTION_LIMIT_TO_A_DEVICE_EXCEEDED:
            return "ERROR_CODE_SYNCHRONOUS_CONNECTION_LIMIT_TO_A_DEVICE_EXCEEDED";
        case ERROR_CODE_ACL_CONNECTION_ALREADY_EXISTS:
            return "ERROR_CODE_ACL_CONNECTION_ALREADY_EXISTS";
        case ERROR_CODE_COMMAND_DISALLOWED:
            return "ERROR_CODE_COMMAND_DISALLOWED";
        case ERROR_CODE_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES:
            return "ERROR_CODE_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES";
        case ERROR_CODE_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS:
            return "ERROR_CODE_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS";
        case ERROR_CODE_CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR:
            return "ERROR_CODE_CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR";
        case ERROR_CODE_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED:
            return "ERROR_CODE_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED";
        case ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE:
            return "ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE";
        case ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS:
            return "ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS";
        case ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION:
            return "ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION";
        case ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES:
            return "ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES";
        case ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF:
            return "ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF";
        case ERROR_CODE_CONNECTION_TERMINATED_BY_LOCAL_HOST:
            return "ERROR_CODE_CONNECTION_TERMINATED_BY_LOCAL_HOST";
        case ERROR_CODE_REPEATED_ATTEMPTS:
            return "ERROR_CODE_REPEATED_ATTEMPTS";
        case ERROR_CODE_PAIRING_NOT_ALLOWED:
            return "ERROR_CODE_PAIRING_NOT_ALLOWED";
        case ERROR_CODE_UNKNOWN_LMP_PDU:
            return "ERROR_CODE_UNKNOWN_LMP_PDU";
        case ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE_UNSUPPORTED_LMP_FEATURE:
            return "ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE_UNSUPPORTED_LMP_FEATURE";
        case ERROR_CODE_SCO_OFFSET_REJECTED:
            return "ERROR_CODE_SCO_OFFSET_REJECTED";
        case ERROR_CODE_SCO_INTERVAL_REJECTED:
            return "ERROR_CODE_SCO_INTERVAL_REJECTED";
        case ERROR_CODE_SCO_AIR_MODE_REJECTED:
            return "ERROR_CODE_SCO_AIR_MODE_REJECTED";
        case ERROR_CODE_INVALID_LMP_PARAMETERS_INVALID_LL_PARAMETERS:
            return "ERROR_CODE_INVALID_LMP_PARAMETERS_INVALID_LL_PARAMETERS";
        case ERROR_CODE_UNSPECIFIED_ERROR:
            return "ERROR_CODE_UNSPECIFIED_ERROR";
        case ERROR_CODE_UNSUPPORTED_LMP_PARAMETER_VALUE_UNSUPPORTED_LL_PARAMETER_VALUE:
            return "ERROR_CODE_UNSUPPORTED_LMP_PARAMETER_VALUE_UNSUPPORTED_LL_PARAMETER_VALUE";
        case ERROR_CODE_ROLE_CHANGE_NOT_ALLOWED:
            return "ERROR_CODE_ROLE_CHANGE_NOT_ALLOWED";
        case ERROR_CODE_LMP_RESPONSE_TIMEOUT_LL_RESPONSE_TIMEOUT:
            return "ERROR_CODE_LMP_RESPONSE_TIMEOUT_LL_RESPONSE_TIMEOUT";
        case ERROR_CODE_LMP_ERROR_TRANSACTION_COLLISION:
            return "ERROR_CODE_LMP_ERROR_TRANSACTION_COLLISION";
        case ERROR_CODE_LMP_PDU_NOT_ALLOWED:
            return "ERROR_CODE_LMP_PDU_NOT_ALLOWED";
        case ERROR_CODE_ENCRYPTION_MODE_NOT_ACCEPTABLE:
            return "ERROR_CODE_ENCRYPTION_MODE_NOT_ACCEPTABLE";
        case ERROR_CODE_LINK_KEY_CANNOT_BE_CHANGED:
            return "ERROR_CODE_LINK_KEY_CANNOT_BE_CHANGED";
        case ERROR_CODE_REQUESTED_QOS_NOT_SUPPORTED:
            return "ERROR_CODE_REQUESTED_QOS_NOT_SUPPORTED";
        case ERROR_CODE_INSTANT_PASSED:
            return "ERROR_CODE_INSTANT_PASSED";
        case ERROR_CODE_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED:
            return "ERROR_CODE_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED";
        case ERROR_CODE_DIFFERENT_TRANSACTION_COLLISION:
            return "ERROR_CODE_DIFFERENT_TRANSACTION_COLLISION";
        case ERROR_CODE_RESERVED:
            return "ERROR_CODE_RESERVED";
        case ERROR_CODE_QOS_UNACCEPTABLE_PARAMETER:
            return "ERROR_CODE_QOS_UNACCEPTABLE_PARAMETER";
        case ERROR_CODE_QOS_REJECTED:
            return "ERROR_CODE_QOS_REJECTED";
        case ERROR_CODE_CHANNEL_CLASSIFICATION_NOT_SUPPORTED:
            return "ERROR_CODE_CHANNEL_CLASSIFICATION_NOT_SUPPORTED";
        case ERROR_CODE_INSUFFICIENT_SECURITY:
            return "ERROR_CODE_INSUFFICIENT_SECURITY";
        case ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE:
            return "ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE";
        case ERROR_CODE_ROLE_SWITCH_PENDING:
            return "ERROR_CODE_ROLE_SWITCH_PENDING";
        case ERROR_CODE_RESERVED_SLOT_VIOLATION:
            return "ERROR_CODE_RESERVED_SLOT_VIOLATION";
        case ERROR_CODE_ROLE_SWITCH_FAILED:
            return "ERROR_CODE_ROLE_SWITCH_FAILED";
        case ERROR_CODE_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE:
            return "ERROR_CODE_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE";
        case ERROR_CODE_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST:
            return "ERROR_CODE_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST";
        case ERROR_CODE_HOST_BUSY_PAIRING:
            return "ERROR_CODE_HOST_BUSY_PAIRING";
        case ERROR_CODE_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND:
            return "ERROR_CODE_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND";
        case ERROR_CODE_CONTROLLER_BUSY:
            return "ERROR_CODE_CONTROLLER_BUSY";
        case ERROR_CODE_UNACCEPTABLE_CONNECTION_PARAMETERS:
            return "ERROR_CODE_UNACCEPTABLE_CONNECTION_PARAMETERS";
        case ERROR_CODE_DIRECTED_ADVERTISING_TIMEOUT:
            return "ERROR_CODE_DIRECTED_ADVERTISING_TIMEOUT";
        case ERROR_CODE_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE:
            return "ERROR_CODE_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE";
        case ERROR_CODE_CONNECTION_FAILED_TO_BE_ESTABLISHED:
            return "ERROR_CODE_CONNECTION_FAILED_TO_BE_ESTABLISHED";
        case ERROR_CODE_MAC_CONNECTION_FAILED:
            return "ERROR_CODE_MAC_CONNECTION_FAILED";
        case ERROR_CODE_COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING:
            return "ERROR_CODE_COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING";
        default:
            return "ERROR_CODE_UNDEFINED";
        }
    }
} // namespace bluetooth
